<!DOCTYPE html>
<html lang=en>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5" />
    <meta name="description" content="Ubuntu 20.04 安装和配置 Redis1.安装并配置Redis更新apt包缓存 1sudo apt update  如果你之间装失败了或担心有残余，可先做清理 1sudo apt-get purge --auto-remove redis-server  输入命令安装Redis 1sudo apt install redis-server  这将下载并安装 Redis 及其依赖项。在此之">
<meta property="og:type" content="article">
<meta property="og:title" content="Ubuntu 20.04 安装和配置 Redis">
<meta property="og:url" content="https://cheung0-bit.github.io/f6acfb74408f/index.html">
<meta property="og:site_name" content="Bruce Zhang&#39;s Blogs">
<meta property="og:description" content="Ubuntu 20.04 安装和配置 Redis1.安装并配置Redis更新apt包缓存 1sudo apt update  如果你之间装失败了或担心有残余，可先做清理 1sudo apt-get purge --auto-remove redis-server  输入命令安装Redis 1sudo apt install redis-server  这将下载并安装 Redis 及其依赖项。在此之">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://0-bit.oss-cn-beijing.aliyuncs.com/168584af0282d27dd80310c811fd45e0.png">
<meta property="og:image" content="https://0-bit.oss-cn-beijing.aliyuncs.com/b15e812e4a43333be24bc876b8445dd8.png">
<meta property="og:image" content="https://0-bit.oss-cn-beijing.aliyuncs.com/73a5b765d7cc84bb38030d7890434899.png">
<meta property="og:image" content="https://0-bit.oss-cn-beijing.aliyuncs.com/73d65bbed3598214fb58fdbfe88aa92f.png">
<meta property="og:image" content="https://0-bit.oss-cn-beijing.aliyuncs.com/8c242dc89daa42a4b18b44a1a3a860ee.png">
<meta property="og:image" content="https://0-bit.oss-cn-beijing.aliyuncs.com/99bfe5c1f790a995fbff37f61f521298.png">
<meta property="article:published_time" content="2021-12-26T13:10:20.000Z">
<meta property="article:modified_time" content="2022-11-25T06:57:36.023Z">
<meta property="article:author" content="张林">
<meta property="article:tag" content="Redis">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://0-bit.oss-cn-beijing.aliyuncs.com/168584af0282d27dd80310c811fd45e0.png">
    
    
      
        
          <link rel="shortcut icon" href="/images/favicon.ico">
        
      
      
        
          <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
        
      
      
        
          <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
        
      
    
    <!-- title -->
    <title>Ubuntu 20.04 安装和配置 Redis</title>
    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">

    <!-- persian styles -->
    
    <!-- rss -->
    
    
      <link rel="alternate" href="/atom.xml" title="Bruce Zhang&#39;s Blogs" type="application/atom+xml" />
    
	<!-- mathjax -->
	
<meta name="generator" content="Hexo 7.0.0"></head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#" aria-label="Menu"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#" aria-label="Menu"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" aria-label="Top" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
        <!--
       --><li><a href="/">Home</a></li><!--
     --><!--
       --><li><a href="/about/">About</a></li><!--
     --><!--
       --><li><a href="/archives/">Articles</a></li><!--
     --><!--
       --><li><a href="/categories/">Category</a></li><!--
     --><!--
       --><li><a href="/search/">Search</a></li><!--
     -->
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" aria-label="Previous post" href="/9949ada0ba31/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" aria-label="Next post" href="/8d02adacbb72/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" aria-label="Back to top" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" aria-label="Share post" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">Previous post</span>
      <span id="i-next" class="info" style="display:none;">Next post</span>
      <span id="i-top" class="info" style="display:none;">Back to top</span>
      <span id="i-share" class="info" style="display:none;">Share post</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://cheung0-bit.github.io/f6acfb74408f/"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://cheung0-bit.github.io/f6acfb74408f/&text=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://cheung0-bit.github.io/f6acfb74408f/&is_video=false&description=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Ubuntu 20.04 安装和配置 Redis&body=Check out this article: https://cheung0-bit.github.io/f6acfb74408f/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://cheung0-bit.github.io/f6acfb74408f/&name=Ubuntu 20.04 安装和配置 Redis&description="><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://cheung0-bit.github.io/f6acfb74408f/&t=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ubuntu-20-04-%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AE-Redis"><span class="toc-number">1.</span> <span class="toc-text">Ubuntu 20.04 安装和配置 Redis</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E5%AE%89%E8%A3%85%E5%B9%B6%E9%85%8D%E7%BD%AERedis"><span class="toc-number">1.1.</span> <span class="toc-text">1.安装并配置Redis</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E6%B5%8B%E8%AF%95Redis"><span class="toc-number">1.2.</span> <span class="toc-text">2.测试Redis</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E7%BB%91%E5%AE%9A%E5%88%B0%E6%9C%AC%E5%9C%B0%E4%B8%BB%E6%9C%BA"><span class="toc-number">1.3.</span> <span class="toc-text">3.绑定到本地主机</span></a></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        Ubuntu 20.04 安装和配置 Redis
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">张林</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2021-12-26T13:10:20.000Z" itemprop="datePublished">2021-12-26</time>
        
        (Updated: <time datetime="2022-11-25T06:57:36.023Z" itemprop="dateModified">2022-11-25</time>)
        
      
    </div>


      
    <div class="article-category">
        <i class="fas fa-archive"></i>
        <a class="category-link" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a>
    </div>


      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link-link" href="/tags/Redis/" rel="tag">Redis</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h2 id="Ubuntu-20-04-安装和配置-Redis"><a href="#Ubuntu-20-04-安装和配置-Redis" class="headerlink" title="Ubuntu 20.04 安装和配置 Redis"></a>Ubuntu 20.04 安装和配置 Redis</h2><h3 id="1-安装并配置Redis"><a href="#1-安装并配置Redis" class="headerlink" title="1.安装并配置Redis"></a>1.安装并配置Redis</h3><p>更新<code>apt</code>包缓存</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt update</span><br></pre></td></tr></table></figure>

<p>如果你之间装失败了或担心有残余，可先做清理</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get purge --auto-remove redis-server</span><br></pre></td></tr></table></figure>

<p>输入命令安装Redis</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install redis-server</span><br></pre></td></tr></table></figure>

<p>这将下载并安装 Redis 及其依赖项。在此之后，Redis 配置文件需要进行一项重要的配置更改，该文件是在安装过程中自动生成的。</p>
<p>打开并编辑配置文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo  vi  /etc/redis/redis.conf</span><br></pre></td></tr></table></figure>

<p>在文件中找到<code>supervised</code>指令，该指令的值默认为<code>no</code>，将其改成<code>systemd</code></p>
<p><img src="https://0-bit.oss-cn-beijing.aliyuncs.com/168584af0282d27dd80310c811fd45e0.png" alt="image-20211226131100882"></p>
<p>保存退出，接下来，重启Redis服务</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl restart redis.service</span><br></pre></td></tr></table></figure>

<h3 id="2-测试Redis"><a href="#2-测试Redis" class="headerlink" title="2.测试Redis"></a>2.测试Redis</h3><p>检查Redis服务是否正常运行</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl status redis</span><br></pre></td></tr></table></figure>

<p>若无错误，则会输出以下内容</p>
<p><img src="https://0-bit.oss-cn-beijing.aliyuncs.com/b15e812e4a43333be24bc876b8445dd8.png" alt="image-20211226131600870"></p>
<p>要测试Redis是否正常运行，可使用<code>redis-cli</code>命令连接到服务器</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">redis-cli</span><br></pre></td></tr></table></figure>

<p>随后，可使用”乒乓”来测试连通性</p>
<p><img src="https://0-bit.oss-cn-beijing.aliyuncs.com/73a5b765d7cc84bb38030d7890434899.png" alt="image-20211226131931414"></p>
<p>接下来，检查您是否能够通过运行来设置密钥：</p>
<p><img src="https://0-bit.oss-cn-beijing.aliyuncs.com/73d65bbed3598214fb58fdbfe88aa92f.png" alt="image-20211226132122146"></p>
<p>成功！退出</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">exit</span><br></pre></td></tr></table></figure>

<h3 id="3-绑定到本地主机"><a href="#3-绑定到本地主机" class="headerlink" title="3.绑定到本地主机"></a>3.绑定到本地主机</h3><p>默认情况下，Redis 只能从<strong>localhost</strong>访问。但是，如果您按照与本教程不同的教程安装和配置了 Redis，则您可能已经更新了配置文件以允许来自任何地方的连接。这不像绑定到<strong>localhost</strong>那样安全。</p>
<p>打开Redis配置文件进行编辑</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vi /etc/redis/redis.conf</span><br></pre></td></tr></table></figure>

<p>找到这一行并确保它没有被注释（<code>#</code>如果存在则删除）</p>
<p><img src="https://0-bit.oss-cn-beijing.aliyuncs.com/8c242dc89daa42a4b18b44a1a3a860ee.png" alt="image-20211226132906974"></p>
<p>然后，重新启动服务以确保 systemd 读取您的更改</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl restart redis</span><br></pre></td></tr></table></figure>

<p>要检查此更改是否已生效，请运行以下<code>netstat</code>命令</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo netstat -lnp | grep redis</span><br></pre></td></tr></table></figure>

<p><img src="https://0-bit.oss-cn-beijing.aliyuncs.com/99bfe5c1f790a995fbff37f61f521298.png" alt="image-20211226133148916"></p>
<p>此输出显示<code>redis-server</code>程序绑定到<strong>localhost</strong> ( <code>127.0.0.1</code>)，反映您刚刚对配置文件所做的更改。如果您在该列中看到另一个 IP 地址（例如<code>0.0.0.0</code>），那么您应该仔细检查您是否取消了对正确行的注释并再次重新启动 Redis 服务。</p>

  </div>
</article>


    <div class="blog-post-comments">
        <div id="utterances_thread">
            <noscript>Please enable JavaScript to view the comments.</noscript>
        </div>
    </div>


        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Articles</a></li>
         
          <li><a href="/categories/">Category</a></li>
         
          <li><a href="/search/">Search</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Ubuntu-20-04-%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AE-Redis"><span class="toc-number">1.</span> <span class="toc-text">Ubuntu 20.04 安装和配置 Redis</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E5%AE%89%E8%A3%85%E5%B9%B6%E9%85%8D%E7%BD%AERedis"><span class="toc-number">1.1.</span> <span class="toc-text">1.安装并配置Redis</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E6%B5%8B%E8%AF%95Redis"><span class="toc-number">1.2.</span> <span class="toc-text">2.测试Redis</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E7%BB%91%E5%AE%9A%E5%88%B0%E6%9C%AC%E5%9C%B0%E4%B8%BB%E6%9C%BA"><span class="toc-number">1.3.</span> <span class="toc-text">3.绑定到本地主机</span></a></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://cheung0-bit.github.io/f6acfb74408f/"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://cheung0-bit.github.io/f6acfb74408f/&text=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://cheung0-bit.github.io/f6acfb74408f/&is_video=false&description=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Ubuntu 20.04 安装和配置 Redis&body=Check out this article: https://cheung0-bit.github.io/f6acfb74408f/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://cheung0-bit.github.io/f6acfb74408f/&title=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://cheung0-bit.github.io/f6acfb74408f/&name=Ubuntu 20.04 安装和配置 Redis&description="><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://cheung0-bit.github.io/f6acfb74408f/&t=Ubuntu 20.04 安装和配置 Redis"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> Menu</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> TOC</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> Share</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> Top</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy;
      
        
          2022-2024
            <a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/">
              苏ICP备2022044873号
            </a>
  </div>
  <div class="footer-right">
    <nav>
      <ul>
        
          <!--
       -->
          <li><a href="/">
              Home
            </a></li>
          <!--
     -->
          
          <!--
       -->
          <li><a href="/about/">
              About
            </a></li>
          <!--
     -->
          
          <!--
       -->
          <li><a href="/archives/">
              Articles
            </a></li>
          <!--
     -->
          
          <!--
       -->
          <li><a href="/categories/">
              Category
            </a></li>
          <!--
     -->
          
          <!--
       -->
          <li><a href="/search/">
              Search
            </a></li>
          <!--
     -->
          
      </ul>
    </nav>
  </div>
</footer>
    </div>
    <!-- styles -->


 
  <link
    rel="preload"
    href="/lib/font-awesome/css/all.min.css"
    as="style"
    onload="this.onload=null;this.rel='stylesheet'"
  />
  <noscript
    ><link
      rel="stylesheet"
      href="/lib/font-awesome/css/all.min.css"
  /></noscript>



    <!-- jquery -->
 
  
<script src="/lib/jquery/jquery.min.js"></script>





<!-- clipboard -->

   
    
<script src="/lib/clipboard/clipboard.min.js"></script>

  
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"Copy to clipboard!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "Copied!");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

  <script type="text/javascript">
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?4484a4a33014b59670c470a6e15a66db";
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(hm, s);
        })();
        </script>

<!-- Cloudflare Analytics -->

<!-- Umami Analytics -->

<!-- Disqus Comments -->

<!-- utterances Comments -->

    <script type="text/javascript">
      var utterances_repo = 'Cheung0-bit/blog-package';
      var utterances_issue_term = 'title';
      var utterances_label = 'Comment';
      var utterances_theme = 'github-dark';

      (function(){
          var script = document.createElement('script');

          script.src = 'https://utteranc.es/client.js';
          script.setAttribute('repo', utterances_repo);
          script.setAttribute('issue-term', 'pathname');
          script.setAttribute('label', utterances_label);
          script.setAttribute('theme', utterances_theme);
          script.setAttribute('crossorigin', 'anonymous');
          script.async = true;
          (document.getElementById('utterances_thread')).appendChild(script);
      }());
  </script>

</body>
</html>
